package com.tinycomment.dbutils;

import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;
//import oracle.sql.BLOB;

public class Parameter {
    private int index=0;
    private Class type=null;
    private Object value = null;
    public Parameter(int index,Class type,Object value){
        this.index = index;
        this.type = type;
        this.value = value;
    }
    
    public void setParameter(PreparedStatement stmt) throws SQLException {  
        if(type == Integer.class){
            stmt.setInt(this.index, SqlHelper.ToInt(this.value));
        }else if(type == String.class){
            stmt.setString(this.index, SqlHelper.ToString(this.value));
        }else if(type == Date.class){
            stmt.setDate(this.index, SqlHelper.ToDate(this.value));
        }else if(type == Long.class){
            stmt.setLong(this.index, SqlHelper.ToLong(this.value));
        }/*else if(type == BLOB.class){
            stmt.setBlob(this.index, (BLOB)this.value);
        }*/
    }
}
